package org.study.binlog4j.boot.handler;

import com.alibaba.fastjson.JSON;
import com.gitee.Jmysy.binlog4j.core.BinlogEvent;
import com.gitee.Jmysy.binlog4j.core.IBinlogEventHandler;
import com.gitee.Jmysy.binlog4j.springboot.starter.annotation.BinlogSubscriber;

/**
 * 作用描述
 *
 * @author doveylovey
 * @version v1.0.0
 * @email 1135782208@qq.com
 * @date 2024年01月16日
 */
@BinlogSubscriber(clientName = "master")
public class BinlogPositionEventHandler implements IBinlogEventHandler {
    @Override
    public void onInsert(BinlogEvent event) {
        System.out.println("插入数据：" + JSON.toJSONString(event));
    }

    @Override
    public void onUpdate(BinlogEvent event) {
        System.out.println("修改数据：" + JSON.toJSONString(event));
    }

    @Override
    public void onDelete(BinlogEvent event) {
        System.out.println("删除数据：" + JSON.toJSONString(event));
    }

    @Override
    public boolean isHandle(String database, String table) {
        //System.out.println("isHandle()方法：database=" + database + "，table=" + table);
        return true;
    }
}
